/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.jr2tecnologia;

import br.com.jr2tecnologia.model.entity.Login;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author ronildo
 */
public class SMSMailUtil {

    public static Object getAttributeInSessionMap(String info){
        FacesContext context = FacesContext.getCurrentInstance();
        Map sessionMap = context.getExternalContext().getSessionMap();
        return sessionMap.get(info);
    }

    public static void putAttributeInSessionMap(String info, Object value){
        FacesContext context = FacesContext.getCurrentInstance();
        Map sessionMap = context.getExternalContext().getSessionMap();
        sessionMap.put(info, value);
    }

    public static Login getLoginInSession(){
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
        return (Login) request.getSession().getAttribute(ConstantsOfSystem.USER_SESSION_KEY);
    }

    public static String getRequestParameterMap(String arg){
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Map map = facesContext.getExternalContext().getRequestParameterMap();
        return (String)map.get(arg);
    }

    public static void putFacesMessage(String title, String msg){
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, title, msg));
    }
}
